package com.companion.companion.controller;

import java.util.List;
import java.util.Map;

import com.companion.companion.domain.Admin;
import com.companion.companion.domain.Serverorder;
import com.companion.companion.domain.Vo.AdminDataIO;
import com.companion.companion.service.IAdminService;
import com.companion.companion.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 管理员信息Controller
 * 
 * @author zly
 * @date 2025-05-06
 */
@CrossOrigin
@RestController
@RequestMapping("/system/admin")
public class AdminController
{
    @Autowired
    private IAdminService adminService;

    /**
     * 查询管理员信息列表
     */
    @ResponseBody
    @GetMapping("/list")
    public List<Admin> list(Admin admin)
    {
        System.out.println("list");
        List<Admin> list = adminService.selectAdminList(admin);
        System.out.println(list);
        return list;
    }

    /**
     * 查询管理员信息列表
     */
    @ResponseBody
    @PostMapping("/main/data")
    public Result mainDataList(@RequestBody Map<String, String> requestBody) {
        Serverorder serverorder = new Serverorder();
        serverorder.setCaregiverName(requestBody.get("nurseName"));
        serverorder.setUserName(requestBody.get("patientName"));
        return Result.success(adminService.selectAdminMainDataList(serverorder));
    }


    /**
     * 获取管理员信息详细信息
     */
    @GetMapping(value = "/{adminId}")
    public Admin getInfo(@PathVariable("adminId") Long adminId)
    {
        return adminService.selectAdminByAdminId(adminId);
    }

    /**
     * 新增管理员信息
     */
    @PostMapping
    public int add(@RequestBody Admin admin)
    {
        return adminService.insertAdmin(admin);
    }

    /**
     * 修改管理员信息
     */
    @PutMapping
    public int edit(@RequestBody Admin admin)
    {
        return adminService.updateAdmin(admin);
    }

    /**
     * 删除管理员信息
     */
	@DeleteMapping("/{adminIds}")
    public int remove(@PathVariable Long[] adminIds)
    {
        return adminService.deleteAdminByAdminIds(adminIds);
    }
}
